package org.example.service.impl;


import org.example.mapper.PerformanceScoreMapper;
import org.example.pojo.EmployeeAndName;
import org.example.pojo.EmployeeScoreVo;
import org.example.pojo.Score;
import org.example.service.PerformanceScoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class PerformanceScoreServiceImpl implements PerformanceScoreService {
    @Autowired
    private PerformanceScoreMapper performanceScoreMapper;

    /**
     * 员工绩效
     *
     * @return {@link List}<{@link EmployeeScoreVo}>
     */
    @Override
    public List<EmployeeScoreVo> selectEmployeeScore() {

        return performanceScoreMapper.selectEmployeeScore();
    }

    /**
     * 查询员工通过id
     *
     * @param id id
     * @return {@link EmployeeAndName}
     */
    @Override
    public EmployeeAndName selectEmployeeById(int id) {
        return performanceScoreMapper.selectEmployeeById(id);
    }

    /**
     * 绩效评分记录
     *
     * @param message 消息
     * @return {@link List}<{@link Score}>
     */
    @Override
    public List<Score> selectScoreRecord(String message) {
        return performanceScoreMapper.selectScoreRecord(message);
    }

    /**
     * 员工评分通过id
     *
     * @param id id
     * @return {@link EmployeeScoreVo}
     */
    @Override
    public EmployeeScoreVo selectEmployeeScoreById(int id) {
        return performanceScoreMapper.selectEmployeeScoreById(id);
    }

    /**
     * 插入分数通过id
     *
     * @param id    id
     * @param grade 年级
     * @return int
     */
    @Override
    public int insertScoreById(int id, int grade) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("id",id);
        map.put("grade",grade);
        return performanceScoreMapper.insertScoreById(map);
    }

    /**
     * 通过名称或id或性别查询
     *
     * @param name 名字
     * @param id   id
     * @param sex  性
     * @return {@link List}<{@link EmployeeScoreVo}>
     */
    @Override
    public List<EmployeeScoreVo> selectByAndNameOrIdOrSex(String name, int id, String sex) {
        Map<String,Object> map = new HashMap<>();
        map.put("name",name);
        map.put("id",id);
        map.put("sex",sex);
        return performanceScoreMapper.selectByAndNameOrIdOrSex(map);
    }

    /**
     * 更新通过id
     *
     * @param id id
     * @return int
     */
    @Override
    public int updateById(int id,int grade) {
        HashMap<String, Integer> map = new HashMap<>();
        map.put("id",id);
        map.put("grade",grade);
        return performanceScoreMapper.updateById(map);

    }
}
